﻿using B.S.Domain.Process.AssignattributesOneModel;
using B.S.Infratrctrue;
using B.S.Requst;
using MediatR;

namespace B.S.Data.MES.API.Applications.AssignattributesOneApplications
{
    public class UpdateAssignattributesOneCommandHorter:IRequestHandler<UpdateAssignattributesOneCommand,APIRequst<int>>
    {
        IBaseRepository<AssignattributesOne> repository;

        public UpdateAssignattributesOneCommandHorter(IBaseRepository<AssignattributesOne> repository)
        {
            this.repository = repository;
        }

        public async Task<APIRequst<int>> Handle(UpdateAssignattributesOneCommand request, CancellationToken cancellationToken)
        {
            var res = new APIRequst<int>();
            var source = await repository.GetById(request.AssignattributesOneId);
            if (source == null)
            {
             
                res.Msg = "没有查找到您所需要的数据";
                return res;
            }
            source.zt = true;
            var del = await repository.Update(source);
            if (del > 0)
            {
                res.Msg = "修改成功";
                res.Data = del;
                return res;
            }
            else
            {
               
                res.Msg = "修改失败";
                res.Data = del;
                return res;
            }
        }
    }
    public class UpdateAssignattributesOnesssssCommandHorter : IRequestHandler<UpdateAssignattributesssOneCommand, APIRequst<int>>
    {
        IBaseRepository<AssignattributesOne> repository;

        public UpdateAssignattributesOnesssssCommandHorter(IBaseRepository<AssignattributesOne> repository)
        {
            this.repository = repository;
        }

        public async Task<APIRequst<int>> Handle(UpdateAssignattributesssOneCommand request, CancellationToken cancellationToken)
        {
            var res = new APIRequst<int>();
            var source = await repository.GetById(request.AssignattributesOneId);
            if (source == null)
            {

                res.Msg = "没有查找到您所需要的数据";
                return res;
            }
            source.zt = false;
            var del = await repository.Update(source);
            if (del > 0)
            {
                res.Msg = "修改成功";
                res.Data = del;
                return res;
            }
            else
            {

                res.Msg = "修改失败";
                res.Data = del;
                return res;
            }
        }
    }
    public class UpdateAssignattributeFangfaOneCommandHorter : IRequestHandler<UpdateAssignattributeFangfaOneCommand, APIRequst<int>>
    {
        IBaseRepository<AssignattributesOne> repository;

        public UpdateAssignattributeFangfaOneCommandHorter(IBaseRepository<AssignattributesOne> repository)
        {
            this.repository = repository;
        }

        public async Task<APIRequst<int>> Handle(UpdateAssignattributeFangfaOneCommand request, CancellationToken cancellationToken)
        {
            var res = new APIRequst<int>();
            var source = await repository.GetById(request.AssignattributesOneId);
            if (source == null)
            {

                res.Msg = "没有查找到您所需要的数据";
                return res;
            }
            source.AssignattributesOnevalue = request.AssignattributesOnevalue;
            var del = await repository.Update(source);
            if (del > 0)
            {
                res.Msg = "修改成功";
                res.Data = del;
                return res;
            }
            else
            {

                res.Msg = "修改失败";
                res.Data = del;
                return res;
            }
        }
    }


    
}
